# -*- coding:utf-8 -*-
import copy
import threading
import pathlib


ABSPATH = pathlib.Path(__file__).resolve().parent.parent

_init_case_data = {"cases": []}


class DB:
    instance = None
    lock = threading.RLock()

    ABSPATH = ABSPATH
    DirName = "testcases"
    case_task_name = ""

    # 是否在录制
    isRecord = False

    # 按钮给过来的录制状态,Start
    recordStatus = ''

    # 判断是否单机，双击，三击，拖动
    beforePressed = {}

    isDrag = False

    # 用例数据
    caseData = {}

    def __new__(cls, *args, **kwargs):
        if cls.instance:
            return cls.instance

        with cls.lock:
            cls.instance = object.__new__(cls)
            return cls.instance

    @classmethod
    def start_record(cls):
        cls.isRecord = True
        cls.caseData = copy.deepcopy(_init_case_data)

    @classmethod
    def stop_record(cls):
        cls.isRecord = False
        # cls.caseData = copy.deepcopy(_init_case_data)
